<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/templates/masterPage.xhtml">

	<ui:define name="pageHeader">
		<div>
			<h1>Files</h1>
		</div>
	</ui:define>

	<ui:define name="content">

		<div>

			<h:outputStylesheet name="css/sheepdog.css"></h:outputStylesheet>
			<h:form id="file_form">




				<p:treeTable id="file_tree" value="#{fileTreeBean.root}"
					selection="#{fileTreeBean.selectedNode}" var="ftc"
					selectionMode="single" liveResize="true"
					styleClass="tables text" emptyMessage="Loading files...">

					<p:ajax event="select" update=":dialog:cont,:dialog:fileName"
						listener="#{fileContentBean.clearContentTT}"
						onstart="PF('fileDialog').show()" />

					<f:facet name="header">
						<p:toolbar>
							<p:toolbarGroup align="left">
								<p:commandButton
									actionListener="#{fileTreeBean.setNeedToReload()}"
									action="#{fileTreeBean.loadData()}" icon="ui-icon-refresh"
									title="Refresh" update="file_tree" />
								<p:separator />
								<p:commandButton actionListener="#{fileTreeBean.expandeAll()}"
									update="file_tree" icon="ui-icon-plus" title="Expande all" />
								<p:commandButton actionListener="#{fileTreeBean.collapseAll()}"
									update="file_tree" icon="ui-icon-minus" title="Collapse all" />

							</p:toolbarGroup>


							<p:toolbarGroup align="right" styleClass="text">
								<h:outputText value="Actual state: " />

								<h:outputText value="${fileTreeBean.actualState}" />
							</p:toolbarGroup>
						</p:toolbar>


					</f:facet>

					<p:column style="text-align: left!important">
						<f:facet name="header">  
               				Name  
           				</f:facet>

						<h:outputText value="#{ftc.file.name}" />
					</p:column>

					<p:column>
						<f:facet name="header">  
               				  Revision
           				</f:facet>

						<h:outputText value="#{ftc.lastRev}" />
					</p:column>

					<p:column>
						<f:facet name="header">  
               				Author  
           				</f:facet>

						<h:outputText value="#{ftc.lastAuthor}" />
					</p:column>

					<p:column>
						<f:facet name="header">  
               				Date 
           				</f:facet>

						<h:outputText value="#{ftc.lastDate}" />
					</p:column>

					<p:column id="subscr_column" styleClass="buttonAlign">
						<f:facet name="header">  
               				Subscription 
           				</f:facet>
						<p:selectBooleanButton id="checkbox" value="#{ftc.subscribed}"
							onIcon="ui-icon-mail-closed" offIcon="ui-icon-close"
							onLabel="Yes" offLabel="No" rendered="#{ftc.file.dir == false}">
							<p:ajax update="checkbox"
								listener="#{subscriptionBean.subscriptionCheck(ftc)}" />
						</p:selectBooleanButton>



					</p:column>




				</p:treeTable>


				<p:remoteCommand name="lazyload" update="file_tree"
					actionListener="#{fileTreeBean.loadData()}" autoRun="true">

				</p:remoteCommand>




			</h:form>

			<ui:insert name="file_content">
				<ui:include src="/templates/file_content.xhtml" />
			</ui:insert>

			<ui:insert name="feedback">
				<ui:include src="/templates/feedback.xhtml" />
			</ui:insert>

		</div>

	</ui:define>



	<ui:define name="footer">
		<div />
	</ui:define>
</ui:composition>